//
//  AppDelegate.m
//  carowner
//
//  Created by 孙可 on 2019/5/10.
//  Copyright © 2019年 ggj. All rights reserved.
//

#import "AppDelegate.h"
#import "HomeController.h"
#import "ServiceController.h"
#import "TradeAreaController.h"
#import "DiscoverController.h"
#import "PersonalController.h"
#import "BaseNavigationController.h"
#import "MainController.h"
#import "LoginController.h"
#import "AMapFoundationKit/AMapFoundationKit.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    //配置高德地图的key
    [AMapServices sharedServices].apiKey = @"4e195eaf6116ec8b57514fa78f399421";
    _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    // Override point for customization after application launch.
    [self setLoginRoot];
    [_window makeKeyAndVisible];
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


-(void)setWelcomeRoot{
    
}

-(void)setLoginRoot{
    LoginController * loginVc = [[LoginController alloc] init];
    [self.window setRootViewController:loginVc];
}


-(void)setMainRoot{
    
    MainController *mainVC = [[MainController alloc] init];
    HomeController * homeVC = [[HomeController alloc] init];
    homeVC.isHiddenTitle = YES;
    ServiceController * serviceVC = [[ServiceController alloc] init];
    serviceVC.isHiddenTitle = YES;
    TradeAreaController * tradeVC = [[TradeAreaController alloc] init];
    tradeVC.isHiddenTitle = NO;
    DiscoverController * disVC = [[DiscoverController alloc] init];
    disVC.isHiddenTitle = YES;
    PersonalController * personalVC = [[PersonalController alloc] init];
    personalVC.isHiddenTitle = YES;
    
    BaseNavigationController * homeNav = [[BaseNavigationController alloc] initWithRootViewController:homeVC];
    
    BaseNavigationController * serviceNav = [[BaseNavigationController alloc] initWithRootViewController:serviceVC];
    
    BaseNavigationController * tradeNav = [[BaseNavigationController alloc] initWithRootViewController:tradeVC];
    
    BaseNavigationController * disNav = [[BaseNavigationController alloc] initWithRootViewController:disVC];
    
    BaseNavigationController * personalNav = [[BaseNavigationController alloc] initWithRootViewController:personalVC];
    
    
    UIImage * homeImage = [UIImage imageNamed:@"icon-btn-sy"];
    UIImage * homeImage1 = [[UIImage imageNamed:@"icon-btn-sy-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    homeNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:homeImage selectedImage:homeImage1];
    [homeNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_unselect_color} forState:UIControlStateNormal];
    [homeNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_select_color} forState:UIControlStateSelected];
    


    
    UIImage * serviceImage = [UIImage imageNamed:@"icon-btn-fw"];
    UIImage * serviceImage1 = [[UIImage imageNamed:@"icon-btn-fw-1"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    serviceNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"服务" image:serviceImage selectedImage:serviceImage1];
    [serviceNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_unselect_color} forState:UIControlStateNormal];
    [serviceNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_select_color} forState:UIControlStateSelected];
    
    
    
    UIImage * tradeImage = [UIImage imageNamed:@"icon-btn-sq"];
    UIImage * tradeImage1 = [[UIImage imageNamed:@"icon-btn-sq-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    tradeNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"商圈" image:tradeImage selectedImage:tradeImage1];
    [tradeNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_unselect_color} forState:UIControlStateNormal];
    [tradeNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_select_color} forState:UIControlStateSelected];
    
    
    
    
    UIImage * disImage = [UIImage imageNamed:@"icon-btn-fj"];
    UIImage * disImage1 = [[UIImage imageNamed:@"icon-btn-fj-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    disNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"发现" image:disImage selectedImage:disImage1];
    [disNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_unselect_color} forState:UIControlStateNormal];
    [disNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_select_color} forState:UIControlStateSelected];
    
    
    UIImage * personalImage = [UIImage imageNamed:@"icon-btn-center"];
    UIImage * personalImage1 = [[UIImage imageNamed:@"icon-btn-center-1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    personalNav.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"个人" image:personalImage selectedImage:personalImage1];
    [personalNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_unselect_color} forState:UIControlStateNormal];
    [personalNav.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:tab_select_color} forState:UIControlStateSelected];

    
    mainVC.viewControllers = @[homeNav,serviceNav,tradeNav,disNav,personalNav];

    
    [self.window setRootViewController:mainVC];
    
}


@end
